package net.ibizsys.eclipse.studio.data;

import com.alibaba.fastjson.JSONObject;

/**
 * 项目
 * 
 * @author <a href='http://www.weibo.com/xjtoo' target='_blank'>Enmaai</a>
 */
public class Project extends IBizData
{
	private String name;
	private String svnurl;
	private boolean readonly;
	private String typeName;

	private ProjectType type;

	private String appname;
	private boolean checked;

	public Project(JSONObject json, String appname)
	{
		this.appname = appname;
		init(json);
	}

	@Override
	public void init(JSONObject json)
	{
		this.name = json.getString("name");
		this.svnurl = json.getString("svnurl");
		this.typeName = json.getString("typename");

		if (json.containsKey("readonly"))
		{
			this.readonly = json.getBoolean("readonly");
		}

		this.type = ProjectType.convert(json.getString("type"));
	}

	public String getName()
	{
		return name;
	}

	public String getSVNUrl()
	{
		return svnurl;
	}

	public ProjectType getType()
	{
		return type;
	}

	public boolean isReadonly()
	{
		return readonly;
	}

	public String getTypeName()
	{
		return typeName;
	}

	public String getAppname()
	{
		return appname;
	}

	public boolean isChecked()
	{
		return checked;
	}

	public void setChecked(boolean checked)
	{
		this.checked = checked;
	}

	@Override
	public String getIcon()
	{
		if (isChecked())
		{
			return "icons/check20.png";
		} else
		{
			return "icons/uncheck20.png";
		}
	}

	@Override
	public String getText()
	{
		return getName();
	}
}
